{extend name="../../common/view/admin_base"/}

{block name="main"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-form-item layui-hide">
                            <label class="layui-form-label">guid</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[guid]" value="{$model.guid|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模块名称</label>
                            <div class="layui-input-inline" style="width:200px;">
                                <input type="text" name="form[module]" value="{$model.module|default=''}" autocomplete="off" placeholder="模块名称" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-inline" style="width:260px;">
                                <input type="text" name="form[name]" value="{$model.name|default=''}" autocomplete="off" placeholder="侧边栏显示的标题" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">图标</label>
                            <div class="layui-input-inline" style="width:240px;">
                                <input type="text" id="icon" name="form[icon]" value="{$model.icon|default=''}" autocomplete="off" placeholder="侧边栏显示的图标" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                <div class="layui-btn" id="iconselected" url="{:url('admin/publics/selecticon')}">选择按钮</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">摘要</label>
                            <div class="layui-input-block" style="width:360px;">
                                <textarea class="layui-textarea" name="form[remark]" lay-verify="content" >{$model.remark|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">主表</label>
                            <div class="layui-input-inline" style="width:180px;">
                                <input type="text" name="form[maintable]" value="{$model.maintable|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">附表</label>
                            <div class="layui-input-inline" style="width:180px;">
                                <input type="text" name="form[extratable]" value="{$model.extratable|default=''}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">序号</label>
                            <div class="layui-input-inline" style="width:80px;">
                                <input type="text" name="form[sort]" value="{$model.sort|default='50'}" autocomplete="off" placeholder="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="commit">提交</button>
                                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="reset">重置</button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['element','layer', 'table','form'], function() {
        var element = layui.element;
        var layer = layui.layer;
        var form = layui.form;

        form.on('submit(commit)', function(obj){
            $.post({
                url:document.URL
                ,type:'post'
                ,data: obj.field
                ,success:function(res){
                    if(res.code == 1){
                        layer.msg(res.msg, {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            top.window.document.location.reload();
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        });

        $("#iconselected").click(function(){
            var url = $(this).attr('url');
            top.layer.open({
                type: 2,
                title: '图标列表',
                shade: 0,
                area: ['780px', '560px'],
                content: url,
                success: function(layero,index){
                    var winname = layero.find('iframe')[0]['name'];
                    top.$("#"+winname).contents().find('.icon-item').on('click',function(){
                        var classname = $(this).find('i').prop('className');
                        $("#icon").val(classname);
                        top.layer.close(index);
                    });
                }
            });
        })
    });

</script>

{/block}